<template>
  <div class="login">
    <div class="login-nav" style="-webkit-app-region: drag">
      <div>
        伯通
      </div>
      <div>
        <div @click="minSizeClick" style="-webkit-app-region: no-drag;">-</div>
        <div @click="closedClick" style="-webkit-app-region: no-drag;">X</div>
      </div>
    </div>
    <div class="login-select" style="-webkit-app-region: no-drag;">
      <div>
        <div @click="loginSelectCLick(1)" :class="{'selectActive':isSelectActive == 1}">
          扫码登录
        </div>
        <div @click="loginSelectCLick(2)" :class="{'selectActive':isSelectActive == 2}">
          密码登录
        </div>
      </div>
    </div>
    <div class="login-headimg" style="-webkit-app-region: no-drag;">
      <div>
        <img :src="headImgVal" alt="">
      </div>
    </div>
    <div class="login-input" style="-webkit-app-region: no-drag;">
      <div>
        <div>
          <input type="text" v-model="account" placeholder="请输入账户">
        </div>
        <div>
          <input type="password" v-model="password" v-on:keyup.13.stop="loginClick" placeholder="请输入密码">
        </div>
      </div>
    </div>
    <div class="login-setting" style="-webkit-app-region: no-drag;">
      <div class="login-setting-left">
        <div v-show="isLoginShow">

        </div>
        <div v-show="!isLoginShow">
          <img src="static/imgs/show.png" alt="">
        </div>
        <div>自动登录</div>
      </div>
      <div class="login-setting-right">
        <div>
          忘记密码
        </div>
        <div>
          新用户注册
        </div>
      </div>
    </div>
    <!-- <div class="login-toast">
      <transition name="slide-fade">
        <div v-show="isToastShow">
          暂不支持此功能
        </div>
      </transition>
    </div> -->
  </div>
</template>

<script>
if (window.require) {
  var ipcRenderer = window.require("electron").ipcRenderer;
}
export default {
  data() {
    return {
      headImgVal: "static/imgs/5.jpg",
      isLoginShow: true, // 是否自动登录
      account: "",
      password: "",
      isSelectActive: 2, // 登录方式选择
      isToastShow: false // 提示弹出框
    };
  },
  created: function() {
    var self = this;
  },
  mounted() {
    // 监听主进程返回的消息
    // ipcRenderer.on('minSizeClickCallBack', function (event, arg) {
    //   console.log(arg);
    // });
  },
  filters: {},
  methods: {
    minSizeClick() {
      ipcRenderer.send("minSizeClick");
    },
    closedClick() {
      ipcRenderer.send("closedClick");
    },
    loginClick() {
      if (this.account == "admin" && this.password == "123456") {
        ipcRenderer.send("GoHOME");
        this.$router.push({
          path: "/home"
        });
      }
    },
    loginSelectCLick(index) {
      this.isSelectActive = index;
    }
  },
  watch: {}
};
</script>

<style scoped>
.login-toast {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-toast > div {
  font-size: 14px;
  color: #ccc;
  width: 120px;
  height: 35px;
  line-height: 35px;
  background-color: #fff;
  text-align: center;
  border-radius: 5px;
}

.login-setting-left {
  display: flex;
  margin-top: 35px;
  margin-left: 33px;
}

.login-setting-left > div:nth-child(1) {
  width: 15px;
  height: 15px;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
}

.login-setting-left > div:nth-child(2) {
  width: 15px;
  height: 15px;
  border-radius: 3px;
  cursor: pointer;
}

.login-setting-left > div:nth-child(2) img {
  width: 100%;
  height: 100%;
}

.login-setting-left > div:nth-child(3) {
  color: #a3a4a6;
  font-size: 12px;
  margin-left: 5px;
  cursor: pointer;
}

.login-setting-left > div:nth-child(3):hover,
.login-setting-right > div:hover {
  color: #49a0fa;
}

.login-setting-right {
  color: #a3a4a6;
  font-size: 12px;
  margin-left: 5px;
  display: flex;
  margin-top: 35px;
}

.login-setting-right > div {
  cursor: pointer;
}

.login-setting-right > div:nth-child(2) {
  margin-left: 12px;
  position: relative;
  margin-right: 30px;
}

.login-setting-right > div:nth-child(2):after {
  position: absolute;
  top: 3px;
  left: -6px;
  width: 1px;
  background-color: #a3a4a6;
  height: 12px;
  content: "";
}

.login-nav {
  height: 45px;
  background-color: #49a0fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-nav > div:nth-child(1) {
  color: #fff;
  font-size: 16px;
  margin-left: 15px;
}

.login-nav > div:nth-child(2) {
  margin-right: 15px;
  display: flex;
}

.login-nav > div:nth-child(2) div {
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.login-nav > div:nth-child(2) div:nth-child(1) {
  font-size: 20px;
  margin-right: 10px;
}

.login-select {
  height: 50px;
}

.login-select > div {
  width: 250px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  height: 35px;
  font-size: 14px;
  color: #a3a4a6;
  line-height: 35px;
  margin-top: 11px;
  /* border: 1px solid red; */
}

.login-select > div > div {
  width: 124px;
  text-align: center;
  border-bottom: 1px solid #ccc;
  cursor: pointer;
}

.login-select > div .selectActive {
  border-bottom: 1px solid #49a0fa !important;
}

.login-select > div > div:hover {
  color: #49a0fa;
}

.login-headimg {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-headimg > div {
  width: 90px;
  height: 90px;
  overflow: hidden;
  border-radius: 50%;
}

.login-headimg > div img {
  width: 100%;
  height: 100%;
}

.login-input {
  height: 100px;
}

.login-input > div {
  width: 250px;
  margin: 0 auto;
}

.login-input > div input {
  width: 245px;
  border: 0;
  border-bottom: 1px solid #ccc;
  font-size: 16px;
  color: #333;
  padding-left: 10px;
}
.login-input > div > div:nth-child(1) {
  margin-top: 5px;
}
.login-input > div > div:nth-child(2) {
  margin-top: 15px;
}
.login-setting {
  height: 95px;
  display: flex;
  justify-content: space-between;
}

.login > div {
  width: 100%;
}

.login {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #fff;
  position: relative;
}

.slide-fade-enter-active {
  transition: all 0.7s ease;
}

.slide-fade-enter,
.slide-fade-leave-active {
  transform: translateY(-30px);
  opacity: 0;
}
</style>